<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :md="6" :sm="24">
            <a-form-item label="姓名">
              <a-input placeholder="请输入姓名" v-model="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="手机号">
              <a-input placeholder="请输入手机号" v-model="queryParam.phone"></a-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="24">
            <a-form-item label="所属驿站">
              <j-search-select-tag placeholder="请输入驿站名称在选择" v-model="queryParam.ssyz" dict="lhyg_corpinfo_yz,corpname,id" :async="true">
              </j-search-select-tag>
            </a-form-item>
          </a-col>

          <a-col :xl="3" :lg="7" :md="5" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <!--<div class="table-operator">-->
<!--      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
<!--      <a-button type="primary" icon="download" @click="handleExportXls('自然人用户')">导出</a-button>-->
<!--      <a-popconfirm title="是否要为选中人员发送引导短信？" @confirm="handleSendSms()">-->
<!--        <a-button type="primary">发送引导短息</a-button>-->
<!--      </a-popconfirm>-->
<!--      <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
        <a-button type="primary" icon="import">导入</a-button>
      </a-upload>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-menu slot="overlay">
          <a-menu-item key="1" @click="batchDel"><a-icon type="delete"/>删除</a-menu-item>
        </a-menu>
        <a-button style="margin-left: 8px"> 批量操作 <a-icon type="down" /></a-button>
      </a-dropdown>-->
    <!--</div>-->

    <!-- table区域-begin -->
    <div>
<!--      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>-->

      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <a  @click="handleDetail(record)">详情</a>
          <a-divider type="vertical" v-if="record.isNuorz == -1 && record.identityType != -1" />
          <a-popconfirm title="确定通过吗?" @confirm="() => handleChange(record.id,1)" v-if="record.isNuorz == -1 && record.identityType != -1">
            <a>通过</a>
          </a-popconfirm>
          <a-divider type="vertical" v-if="record.isNuorz == -1 && record.identityType != -1" />
          <a-popconfirm title="确定驳回吗?" @confirm="() => handleChange(record.id,0)" v-if="record.isNuorz == -1 && record.identityType != -1">
            <a>驳回</a>
          </a-popconfirm>

          <!--<a-divider type="vertical" v-if="record.pwd != null && record.pwd != ''" />
          <a v-if="record.pwd != null && record.pwd != ''" @click="viewHt(record)">合同</a>-->
        </span>
      </a-table>
    </div>

    <a-modal
      title="查看合同"
      :visible="visibleHz"
      width="1000px"
      cancelText="关闭"
      @cancel="HzClose"
      :okButtonProps="{ class:{'jee-hidden': true} }"
    >
      <div  id="hz" style="width:960px;height:600px;">
        <iframe style="width: 100%;height: 100%;" :src="hzImgUrl"></iframe>
      </div>
    </a-modal>

    <lhyg-pt-user-modal ref="modalForm" @ok="modalFormOk"></lhyg-pt-user-modal>
  </a-card>
</template>

<script>

  import '@/assets/less/TableExpand.less'
  import { mixinDevice } from '@/utils/mixin'
  import { JeecgListMixin } from '@/mixins/JeecgListMixin'
  import LhygPtUserModal from './modules/LhygPtUserModal'
  import { httpAction, getAction, postAction } from '@/api/manage'
  import JDictSelectTag from '@/components/dict/JDictSelectTag.vue'
  import JSearchSelectTag from '@/components/dict/JSearchSelectTag'

  export default {
    name: 'GeneralUserList',
    mixins:[JeecgListMixin, mixinDevice],
    components: {
      LhygPtUserModal,
      JDictSelectTag,
      JSearchSelectTag
    },
    data () {
      return {
        description: '自然人管理页面',
        // 表头
        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title:'注册时间',
            align:"center",
            dataIndex: 'createTime',
            customRender:function (text) {
              return !text?"":(text.length>10?text.substr(0,10):text)
            }
          },
          {
              title:'姓名',
              align:"center",
              dataIndex: 'name'
          },
          {
              title:'手机号',
              align:"center",
              dataIndex: 'phone'
          },
          {
            title:'身份证号',
            align:"center",
            dataIndex: 'identityid'
          },
          {
            title:'银行名称',
            align:"center",
            dataIndex: 'bankname'
          },
          {
            title:'银行卡号',
            align:"center",
            dataIndex: 'cardnumber'
          },
          {
            title: '操作',
            dataIndex: 'action',
            align:"center",
            fixed:"right",
            width:147,
            scopedSlots: { customRender: 'action' }
          }
        ],
        url: {
          updateStatus: "/wx/lhygWxUser/updateStatus",
          list: "/wx/qyUser/generalUserPtList",
          delete: "/wx/qyUser/delete",
          deleteBatch: "/wx/qyUser/deleteBatch",
          exportXlsUrl: "/wx/qyUser/exportXlsForGeneralUser",
          importExcelUrl: "wx/qyUser/importExcel",
          getBussInfo: "/push/getBussInfo",
          sendSms: "wx/qyUser/sendSms"
        },
        dictOptions:{},
        visibleHz: false,
        hzImgUrl: '',
      }
    },
    created() {
    },
    computed: {
      importExcelUrl: function(){
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
      },
    },
    methods: {
      initDictConfig(){
      },
      viewHt(record){
        this.hzImgUrl = record.files;
        this.visibleHz = true;
      },
      HzClose(){
        this.visibleHz = false;
      },
      getBussInfo(record){
        const that = this;
        let formData=new FormData();
        formData.append('identityid', record.identityid);
        formData.append('industryco', record.industryco);
        postAction(this.url.getBussInfo, formData).then((res)=>{
          if (res.success) {
            that.$message.success(res.message);
            //this.onClearSelected();
            this.loadData();
          } else {
            that.$message.warning(res.message);
            this.loadData();
          }
        })
      },
      handleSendSms() {
        let that = this
        if(that.selectedRowKeys.length > 0){
          var ids = "";
          for (var a = 0; a < this.selectedRowKeys.length; a++) {
            ids += this.selectedRowKeys[a] + ",";
          }
          let formData=new FormData();
          formData.append('ids', ids);
          postAction(that.url.sendSms, formData).then((res)=>{
            if(res.success){
              that.onClearSelected();
              that.loadData();
            } else {
              that.$message.warning("短信发送失败");
            }
          })
        } else {
          that.$message.warning("请选择至少一条未工商注册的自然人发送引导短信");
        }
      }
    }
  }
</script>
<style scoped>
  @import '~@assets/less/common.less';
</style>
